<?php
	$mp_op_id = $_GET['mp_op_id'];
	$client_id = '13103';
	$client_secret = '07mGvmOJuadpsWsz499GyDtg8gyaDBnK';
	$data [] = 'grant_type=client_credentials';
	$data [] = 'client_id=' . $client_id;	
	$data [] = 'client_secret=' . $client_secret;

	$qs = implode ( '&', $data );

	$url = 'https://api.mercadolibre.com/oauth/token';
	$result = micurl($qs,$url);

	$json = $result['response'];
	$jsondecode = json_decode($json);

	echo "<pre>";
	print_r($result);
	echo "</pre>";

	echo "<pre>";
	print_r($jsondecode);
	echo "</pre>";
	$Token = $jsondecode->access_token;


	//https://api.mercadolibre.com/collections/436820489?access_token=APP_USR-13103-091810-ec32a74add72e26b94199b05d482e5da-122143112

	$datos = file_get_contents("https://api.mercadolibre.com/collections/$mp_op_id?access_token=$Token");

	echo "<pre>";
	print_r(json_decode($datos));
	echo "</pre>";



	function micurl($qs,$url){
		$handler = curl_init ();
		curl_setopt ( $handler, CURLOPT_URL, $url );
		curl_setopt ( $handler, CURLOPT_POST, true );
		curl_setopt ( $handler, CURLOPT_POSTFIELDS, $qs );
		curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
		$response = curl_exec ( $handler );
		$return = array ('response' => $response, 'data' => curl_getinfo ( $handler ) );
		curl_close ( $handler );
		return $return;
	}

?>